/*
 * @Author: zxh
 * @Date: 2024-07-19 17:04:33
 * @LastEditors: zxh
 * @LastEditTime: 2024-07-24 15:36:18
 * @Description: 请填写简介
 */
import { ref, computed } from 'vue'
// 导入一个方法 defineStore
import { defineStore } from 'pinia'

export const useCounterStore = defineStore('counter', () => {
  // 定义数据 state
  const count = ref(0)
  const doubleCount = computed(() => count.value * 2)

  //定义修改数据的方法(action 同步+异步)
  function increment() {
    count.value++
  }

  // 以对象的方式return供组件使用
  return { count, doubleCount, increment }
})
